package com.controller;

import com.entity.User;
import com.services.UserServiceI;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.PostConstruct;

@RestController
@RequestMapping("/user")
@Api(tags = "用户接口2",value = "用户controller")
public class UserController {
    @Autowired
    private UserServiceI userServiceI;



        @RequestMapping(value="/{id}",method = RequestMethod.GET)
        @ApiOperation(value = "用户查询",httpMethod = "GET")
        @ApiImplicitParams({
                @ApiImplicitParam(name = "id",value = "用户ID",required = true)
        })
        public String findUser(@PathVariable("id")Integer id){
            System.out.println("访问成功!");
           // return userServiceI.findUserById(id);
            return "index";
        }

        //测试forword转发
//        @RequestMapping("/forword")
//        public String forword(){
//
//        return "cui";
//    }

    @PostConstruct  //@PostConstruct是java5的时候引入的注解，指的是在项目启动的时候执行这个方法，也可以理解为在spring容器启动的时候执行
    public void testPostConstruct(){
        System.out.println("测试@PostConstruct");
    }

    @RequestMapping("/login")
    public ModelAndView login() {
        ModelAndView m= new ModelAndView();
        m.setViewName("cui");
        return m;
    }
    @RequestMapping("/find")
    public User find(String name, String password){
        User a = new User();
        a.setName(name);
        a.setPassword(password);
        return a;
    }
}






















